//
//  CustomerContractDetailViewController.m
//  EPBPro
//
//  Created by wucha on 2018/6/27.
//  Copyright © 2018年 fc. All rights reserved.
//

#import "CustomerContractDetailViewController.h"
#import "ResizeView.h"

@interface CustomerContractDetailViewController ()
@property (nonatomic,strong) CustomerContractInfo *customerContractInfo;
@end

@implementation CustomerContractDetailViewController

-(id)initWithCustomerContract:(CustomerContractInfo*)customerContractInfo{
    if (self == [super init]) {
        self.customerContractInfo = customerContractInfo;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.titleName = @"合同详情";
    ResizeView *resizeView = [[ResizeView alloc] initWithFrame:CGRectMake(0, StatusBarHeight+44, SCREEN_WIDTH, SCREEN_HEIGHT-StatusBarHeight-44)];
    [self.view addSubview:resizeView];
    
    [resizeView addResizeSubview:[self getSpaceResizeViewInfo:10]];
    [resizeView addResizeSubview:[self getNormalResizeViewInfo:@"合同编号" value:self.customerContractInfo.id]];
    [resizeView addResizeSubview:[self getNormalResizeViewInfo:@"投资人" value:self.customerContractInfo.contactor]];
    [resizeView addResizeSubview:[self getNormalResizeViewInfo:@"联系方式" value:self.customerContractInfo.contactPhone]];

    [resizeView addResizeSubview:[self getNormalResizeViewInfo:@"有效期" value:[NSString stringWithFormat:@"%@到%@",[Utils dateChineseToString:[Utils stringToDate:self.customerContractInfo.startDate]],[Utils dateChineseToString:[Utils stringToDate:self.customerContractInfo.endDate]]]]];
    [resizeView addResizeSubview:[self getNormalResizeViewInfo:@"金额" value:self.customerContractInfo.amount]];
    [resizeView addResizeSubview:[self getNormalResizeViewInfo:@"机器数量" value:self.customerContractInfo.equipmentNum]];
    [resizeView addResizeSubview:[self getNormalResizeViewInfo:@"投放区域" value:@"xxxxxxxxx"]];
    
}

-(ResizeViewInfo*)getNormalResizeViewInfo:(NSString*)title value:(NSString*)valueString{
    ResizeViewInfo *resizeViewInfo = [[ResizeViewInfo alloc] init];
    resizeViewInfo.height = 44;
    resizeViewInfo.view.backgroundColor = [UIColor whiteColor];
    
    UILabel *titleLabel = [UILabel new];
    titleLabel.text = title;
    titleLabel.font = [UIFont systemFontOfSize:16];
    [resizeViewInfo addSubview:titleLabel];
    titleLabel.sd_layout.leftSpaceToView(resizeViewInfo.view, 15).topSpaceToView(resizeViewInfo.view, 0).bottomSpaceToView(resizeViewInfo.view, 0).widthIs(100);
    
    UILabel *nameLabel = [UILabel new];
    nameLabel.text = valueString;
    nameLabel.textColor = [UIColor grayColor];
    nameLabel.font = [UIFont systemFontOfSize:16];
    nameLabel.textAlignment = NSTextAlignmentRight;
    [resizeViewInfo addSubview:nameLabel];
    nameLabel.sd_layout.rightSpaceToView(resizeViewInfo.view, 15).topSpaceToView(resizeViewInfo.view, 0).bottomSpaceToView(resizeViewInfo.view, 0).autoWidthRatio(0);
    [nameLabel setSingleLineAutoResizeWithMaxWidth:300];
    
    return resizeViewInfo;
}

-(ResizeViewInfo*)getSpaceResizeViewInfo:(int)height{
    ResizeViewInfo *resizeViewInfo = [[ResizeViewInfo alloc] init];
    resizeViewInfo.height = height;
    
    return resizeViewInfo;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
